/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.prueba.controlador;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;


/**
 *
 * @author 43579648
 */
public class Conexion {

    public Conexion() {
    }
    
    
    private static Connection conexion;

    private static void cargarConexion() throws Exception{
        String url ="jdbc:as400://pub1.rzkh.de;naming=sql;errors=full";
        String usuario ="GMARTINEZ";
        String pass ="ITCOMSV";
        try{
            Class.forName("com.ibm.as400.access.AS400JDBCDriver");
            conexion = DriverManager.getConnection(url,usuario,pass);
        }catch(Exception e){
            throw e;
        }
    }

    public static Connection getConexion() throws Exception {
        if(conexion==null || conexion.isClosed())
            cargarConexion();
        return conexion;
    }
    
    
    
}
